from Test import AbstractTest
from MySocket import User, Event
'''
1. Create two users
2. Sends a follow message from user #1 to #2
3. User #2 should receive notification
'''
class TestFollowMessage(AbstractTest):
    def __init__(self):
        test_name = "Follow Message Test"
        super(TestFollowMessage, self).__init__(test_name)

    def run(self):
        # message to be sent
        message = "1|F|1|2\n"
        user_1 = User()
        user_2 = User()
        # connect all the users
        user_1.connect()
        user_2.connect()
        # send id
        user_1.mysend("1\n")
        user_2.mysend("2\n")
        # create event
        event = Event()
        event.connect()
        event.mysend(message)
        # validation
        if(user_2.myreceive(len(message)) != message):
            return False;
        return True